# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=serializationdumper
pkgver=34.6d161cd
pkgrel=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-reversing')
pkgdesc='A tool to dump Java serialization streams in a more human readable form.'
arch=('any')
url='https://github.com/NickstaDB/SerializationDumper/'
license=('MIT')
depends=('java-runtime' 'java-environment')
makedepends=('git')
source=("$pkgname::git+https://github.com/NickstaDB/SerializationDumper.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  chmod +x build.sh
}

build() {
  cd "$pkgname"

  ./build.sh
}

package() {
  cd "$pkgname"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
java -jar /usr/share/$pkgname/SerializationDumper.jar "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

